home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
201-220
/
scopedisk202
/
bbbbs2
/
rexxdoors
/
grin_du_jour.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-03-19
|
1KB
|
41 lines
/* Grin_du_Jour.rexx - uses micros to pick 1 of 3000 locations */
FF='0C'x /* FormFeed */
CR='0D'x /* Carraige Return */
SIGNAL ON BREAK_C
SIGNAL ON BREAK_E
ARG name .
bbspath=GETCLIP('BBS_path')
filename=bbspath'rexxDoors/Data/Grins' /* Formfeed separated text */
size=WORD(STATEF(filename),2)
size=TRUNC(size-(size/3000)) /* allow for last grin */
x=OPEN(f,'RAM:DUMMY','W') /* write to a dummy file */
IF x=0 THEN RETURN(20);
CALL WRITELN(f,'dummy')
CALL CLOSE(f)
micros=WORD(STATEF('RAM:DUMMY'),7) /* get the microseconds */
location=TRUNC(size*(micros/3000)) /* 0 >= micros < 3000 */
x=OPEN(f,filename,'R')
IF x=0 THEN RETURN(10);
CALL SEEK(f,location,'B') /* point to the random place */
line=''
DO WHILE line~=FF & ~EOF(f) /* find the start (a formfeed) */
line=READLN(f)
END
line=''
IF ~EOF(f) THEN /* if EOF then must be right at end. missed! */
DO WHILE line~=FF & ~EOF(f) /* otherwise, show the page */
line=READLN(f)
IF ~EOF(f) & line~=FF THEN SAY line||CR
END
BREAK_C:
BREAK_E:
CALL CLOSE(f)
RETURN(0);
EXIT; /* a little redundant, so sue me! */